def degree_order( s ):
    if '学士' == s:
        return 0
    elif '硕士' == s:
        return 1
    elif '博士' == s:
        return 2
    else:
        return -1

names = ["学士", "硕士", "博士", "学士", "博士"]
names.sort(key=degree_order)
print(names)
names.sort(key=degree_order, reverse=True)
print(names)
